October Listing
         TTL "Listing One: Indexed Modes Ex."
;
;
;
**********************************
*                                *
* Listing One:                   *
* Indexed Addressing Modes       *
* Example Program.               *
*                                *
**********************************
;
;
;
*************
* CONSTANTS *
*************
;
;
FALSE    EQU 0
TRUE     EQU 1
CR       EQU $8D
;
;
;
; "IF" STATEMENT EQUATES
;
;
EQ       EQU "="
NE       EQU "#"
GT       EQU ">"
LT       EQU "<"
GE       EQU ">"|"="*256
LE       EQU "<"|"="*256
;
;
;
;
;
;
;
**************************
* SPEED/ASM ENTRY POINTS *
**************************
;
;
;
;
; NOTE: TOE EQUATE OF FUTC MUST
; BE (BANGED IF YOU RELOCATE
; SPEED/ASM TO SOME LOCATION
; OTHER THAN $7800
;
;
;
PUTC     EQU $7800
GETC     EQU PUTC+3
SAGL     EQU GETC+3          ;FOR USE BY S/A ONLY- SEE DOC.
SAPC     EQU SAGL+3          ; "   "   "  "   "     "  "
HOME     EQU SAPC+3          ;HOME AND CLEAR
READLN   EQU HOME+3
INIT     EQU READLN+3
FOR      EQU INIT+3
FOR0     EQU FOR+3
NEXT     EQU FOR0+3
IFI      EQU NEXT+3
IFI0     EQU IFI+3
IFS      EQU IFI0+3
IFS0     EQU IFS+3
MOVE     EQU IFS0+3
LOAD     EQU MOVE+3
MOVS     EQU LOAD+3
LDSTR    EQU MOVS+3
PRINT    EQU LDSTR+3
PRTSTR   EQU PRINT+3
PRTINT   EQU PRTSTR+3
RDSTR    EQU PRTINT+3
RDINT    EQU RDSTR+3
;
ABS      EQU RDINT+18
NEG      EQU ABS+3
MUL      EQU NEG+3
DIV      EQU MUL+3
MOD      EQU DIV+3
RND      EQU MOD+3
SUBSTR   EQU RND+3
INDEX    EQU SUBSTR+3
LENGTH   EQU INDEX+3
CONCAT   EQU LENGTH+3
;
;
;
;
; Apple monitor equate
;
EXIT     EQU $FF69
;
********************************
*
*
* Sample program for Assembly
* Advantage Part six.
*
* Demonstration of the 6502
* indexed addressing modes.
*
********************************
;
;
BEGIN    JSR INIT            ;Always call this first
;
         JSR HOME
;
         JSR PRINT
         BYT CR,CR,CR
         BYT "This program counts the number of",CR
         BYT "Alphabetic, Vowels, Numeric, and",CR
         BYT "Non-numeric characters found on an",CR
         BYT "input line.",CR
         BYT CR
         BYT "   To terminate the program press"
         BYT "space as the first character on",CR
         BYT "the line.",CR,CR
         BYT 0
;
;
READLOOP JSR PRINT
         BYT CR,"Enter a line of text: ",0
         JSR READLN
         JSR RDSTR
         ADR INPUTSTR
;
; See if the first character is a space
;
         LDA INPUTSTR+1
         CMP #" "
         BNE NOEXIT
         JMP EXIT
;
;
; Now count the vowels, alphabetic^
; numerics, and other chars*
;
NOEXIT   JSR LOAD
         ADR 0,VOWEL
         JSR LOAD
         ADR 0,ALPHAS
         JSR LOAD
         ADR 0,NUMERICS
         JSR LOAD
         ADR 0,CHARS
;
         LDX #0
CNTLOOP  LDA INPUTSTR+1,X    ; Get char.
         BNE TSTALPHA
;
;
; If at the end of the line, print
; the data out*
;
         JSR PRINT
         BYT CR,CR,"Number of vowels: ",0
         JSR PRTINT
         ADR VOWEL
;
         JSR PRINT
         BYT CR,"Number of alphabetics: ",0
         JSR PRTINT
         ADR ALPHAS
;
         JSR PRINT
         BYT CR,"Number of numerics: ",0
         JSR PRTINT
         ADR NUMERICS
;
         JSR PRINT
         BYT CR,"Number of characters: ",0
         JSR PRTINT
         ADR CHARS
         JMP READLOOP
;
;
; First, count the alphabetic chars
;
TSTALPHA CMP #"A"
         BLT NOTALPHA
         CMP #"Z"+1
         BLT ISALPHA
         CMP #"a"
         BLT NOTALPHA
         CMP #"z"+1
         BGE NOTALPHA
;
ISALPHA  CLC 
         LDA #1
         ADC ALPHAS
         STA ALPHAS
         LDA /1
         ADC ALPHAS+1
         STA ALPHAS+1
;
;
; Now count the vowels
;
NOTALPHA LDA INPUTSTR+1,X
         LDY #13
VWLCMP   CMP VOWELS,Y
         BEQ ISAVWL
         DEY 
         BPL VWLCMP
         BMI NOTAVWL
;
ISAVWL   CLC 
         LDA #1
         ADC VOWEL
         STA VOWEL
         LDA /1
         ADC VOWEL+1
         STA VOWEL+1
;
;
;
; If numeric, increment that counter,
;
;
NOTAVWL  LDA INPUTSTR+1,X
         CMP #"0"
         BLT NOTANUM
         CMP #"9"+1
         BGE NOTANUM
;
         CLC 
         LDA NUMERICS
         ADC #1
         STA NUMERICS
         LDA NUMERICS+1
         ADC /1
         STA NUMERICS+1
;
;
;
; Increment the character count
;
NOTANUM  CLC 
         LDA CHARS
         ADC #1
         STA CHARS
         LDA CHARS+1
         ADC /1
         STA CHARS+1
;
; Move on to next character and repeat
;
         INX 
         JMP CNTLOOP
;
;
;
;
VOWELS   BYT "AEIOUYWaeiouyw"
;
;
VOWEL    ADR 0
ALPHAS   ADR 0
NUMERICS ADR 0
CHARS    ADR 0
;
;
INPUTSTR ADR 128
         DFS 128
;
         END